import request from '@/utils/request'

// 查询帖子列表
export function listPost(query) {
  return request({
    url: '/campus/post/list',
    method: 'get',
    params: query
  })
}

// 查询帖子详细
export function getPost(id) {
  return request({
    url: '/campus/post/' + id,
    method: 'get'
  })
}

// 查询帖子详情（包含评论）
export function getPostDetail(id) {
  return request({
    url: '/campus/post/info/' + id,
    method: 'get'
  })
}

// 新增帖子
export function addPost(data) {
  return request({
    url: '/campus/post',
    method: 'post',
    data: data
  })
}

// 修改帖子
export function updatePost(data) {
  return request({
    url: '/campus/post',
    method: 'put',
    data: data
  })
}

// 删除帖子
export function delPost(id) {
  return request({
    url: '/campus/post/' + id,
    method: 'delete'
  })
}

// 帖子点赞
export function likePost(id) {
  return request({
    url: '/campus/post/' + id + '/like',
    method: 'put'
  })
}

// 根据帖子ID查询评论列表
export function listPostComments(postId) {
  return request({
    url: '/campus/comment/list',
    method: 'get',
    params: { postId: postId }
  })
}

// 添加评论
export function addPostComment(data) {
  return request({
    url: '/campus/comment',
    method: 'post',
    data: data
  })
}